parameters:
  jobTemplate: ''
  variables: []
  osGroup: ''
  osSubgroup: ''
  archType: ''
  container: ''
  pool: ''
  platform: ''
  shouldContinueOnError: false
  jobParameters: {}

jobs:
- template: ${{ parameters.jobTemplate }}
  parameters:
    variables: ${{ parameters.variables }}
    osGroup: ${{ parameters.osGroup }}
    osSubgroup: ${{ parameters.osSubgroup }}
    archType: ${{ parameters.archType }}
    container: ${{ parameters.container }}
    pool: ${{ parameters.pool }}
    platform: ${{ parameters.platform }}
    shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
    helixQueues:

    # Linux arm
    - ${{ if eq(parameters.platform, 'linux_arm') }}:
      - ${{ if or(eq(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
        - (Debian.11.Arm32.Open)Ubuntu.2004.ArmArch.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-helix-arm32v7

    # Linux armv6
    - ${{ if eq(parameters.platform, 'linux_armv6') }}:
      - (Raspbian.10.Armv6.Open)Ubuntu.2004.ArmArch.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:raspbian-10-helix-arm32v6

    # Linux arm64
    - ${{ if eq(parameters.platform, 'linux_arm64') }}:
      - (Ubuntu.2204.Arm64.Open)Ubuntu.2004.ArmArch.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-helix-arm64v8
      - ${{ if or(ne(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
        - (Debian.11.Arm64.Open)Ubuntu.2004.Armarch.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-helix-arm64v8

    # Linux musl x64
    - ${{ if eq(parameters.platform, 'linux_musl_x64') }}:
      - ${{ if or(ne(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
        - (Alpine.316.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.16-helix-amd64
      - ${{ if or(eq(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
        - (Alpine.318.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.18-helix-amd64

    # Linux musl arm64
    - ${{ if and(eq(parameters.platform, 'linux_musl_arm64'), or(eq(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true))) }}:
      - (Alpine.318.Arm64.Open)ubuntu.2004.armarch.open@mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.18-helix-arm64v8
      - (Alpine.316.Arm64.Open)ubuntu.2004.armarch.open@mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.16-helix-arm64v8

    # Linux x64
    - ${{ if eq(parameters.platform, 'linux_x64') }}:
      - ${{ if and(eq(parameters.jobParameters.interpreter, ''), ne(parameters.jobParameters.isSingleFile, true)) }}:
        - ${{ if and(eq(parameters.jobParameters.testScope, 'outerloop'), eq(parameters.jobParameters.runtimeFlavor, 'mono')) }}:
          - SLES.15.Amd64.Open
          - (Centos.8.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8-helix
          - (Fedora.38.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-38-helix
          - (Ubuntu.2204.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-helix-amd64
          - (Debian.11.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-helix-amd64
        - ${{ if or(ne(parameters.jobParameters.testScope, 'outerloop'), ne(parameters.jobParameters.runtimeFlavor, 'mono')) }}:
          - ${{ if or(eq(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
            - SLES.15.Amd64.Open
            - (Fedora.38.Amd64.Open)ubuntu.2204.amd64.open@mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-38-helix
            - Ubuntu.2204.Amd64.Open
            - (Debian.11.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-helix-amd64
            - (Mariner.2.0.Amd64.Open)Ubuntu.2204.Amd64.open@mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-helix-amd64
            - (openSUSE.15.2.Amd64.Open)Ubuntu.2204.Amd64.open@mcr.microsoft.com/dotnet-buildtools/prereqs:opensuse-15.2-helix-amd64
          - ${{ if or(ne(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
            - (Centos.8.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8-helix
            - (Debian.11.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-helix-amd64
            - Ubuntu.2204.Amd64.Open
      - ${{ if or(eq(parameters.jobParameters.interpreter, 'true'), eq(parameters.jobParameters.isSingleFile, true)) }}:
        # Limiting interp runs as we don't need as much coverage.
        - (Debian.11.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-helix-amd64

    # Linux s390x
    - ${{ if eq(parameters.platform, 'linux_s390x') }}:
        - Ubuntu.2004.S390X.Experimental.Open

    # Linux PPC64le
    - ${{ if eq(parameters.platform, 'linux_ppc64le') }}:
        - Ubuntu.2204.PPC64le.Experimental.Open

    # OSX arm64
    - ${{ if eq(parameters.platform, 'osx_arm64') }}:
      - OSX.1200.ARM64.Open

    # OSX x64
    - ${{ if eq(parameters.platform, 'osx_x64') }}:
      - OSX.1200.Amd64.Open

    # Android
    - ${{ if in(parameters.platform, 'android_x86', 'android_x64', 'linux_bionic_x64') }}:
      - Ubuntu.2204.Amd64.Android.29.Open
    - ${{ if in(parameters.platform, 'android_arm', 'android_arm64', 'linux_bionic_arm', 'linux_bionic_arm64') }}:
      - Windows.11.Amd64.Android.Open

    # iOS Simulator/Mac Catalyst arm64
    - ${{ if in(parameters.platform, 'maccatalyst_arm64', 'iossimulator_arm64') }}:
      - OSX.1200.Arm64.Open

    # iOS/tvOS Simulator x64 & MacCatalyst x64
    - ${{ if in(parameters.platform, 'iossimulator_x64', 'tvossimulator_x64', 'maccatalyst_x64') }}:
      - OSX.1200.Amd64.Open

    # iOS devices
    - ${{ if in(parameters.platform, 'ios_arm64') }}:
      - OSX.13.Amd64.Iphone.Open

    # tvOS devices
    - ${{ if in(parameters.platform, 'tvos_arm64') }}:
      - OSX.13.Amd64.AppleTV.Open

    # windows x64
    - ${{ if eq(parameters.platform, 'windows_x64') }}:
      # netcoreapp
      - ${{ if notIn(parameters.jobParameters.framework, 'net48') }}:
        # libraries on mono outerloop
        - ${{ if and(eq(parameters.jobParameters.testScope, 'outerloop'), eq(parameters.jobParameters.runtimeFlavor, 'mono')) }}:
          - Windows.Amd64.Server2022.Open
        # libraries on coreclr (outerloop and innerloop), or libraries on mono innerloop
        - ${{ if or(ne(parameters.jobParameters.testScope, 'outerloop'), ne(parameters.jobParameters.runtimeFlavor, 'mono')) }}:
          - ${{ if or(eq(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
            - Windows.Amd64.Server2022.Open
            - ${{ if ne(parameters.jobParameters.testScope, 'outerloop') }}:
              - (Windows.10.Amd64.ServerRS5.Open)windows.10.amd64.serverrs5.open@mcr.microsoft.com/dotnet-buildtools/prereqs:windowsservercore-ltsc2019-helix-amd64
          - ${{ if or(ne(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
            - Windows.81.Amd64.Open
            - Windows.Amd64.Server2022.Open
            - Windows.11.Amd64.Client.Open
            - ${{ if eq(parameters.jobParameters.testScope, 'outerloop') }}:
              - (Windows.10.Amd64.ServerRS5.Open)windows.10.amd64.serverrs5.open@mcr.microsoft.com/dotnet-buildtools/prereqs:windowsservercore-ltsc2019-helix-amd64
            - ${{ if ne(parameters.jobParameters.runtimeFlavor, 'mono') }}:
              - (Windows.Nano.1809.Amd64.Open)windows.10.amd64.serverrs5.open@mcr.microsoft.com/dotnet-buildtools/prereqs:nanoserver-1809-helix-amd64

      # .NETFramework
      - ${{ if eq(parameters.jobParameters.framework, 'net48') }}:
        - Windows.11.Amd64.Client.Open


    # windows x86
    - ${{ if eq(parameters.platform, 'windows_x86') }}:
      # netcoreapp
      - ${{ if notIn(parameters.jobParameters.framework, 'net48') }}:
        # mono outerloop
        - ${{ if and(eq(parameters.jobParameters.testScope, 'outerloop'), eq(parameters.jobParameters.runtimeFlavor, 'mono')) }}:
          - Windows.7.Amd64.Open
          - Windows.11.Amd64.Client.Open
        # libraries on coreclr (outerloop and innerloop), or libraries on mono innerloop
        - ${{ if or(ne(parameters.jobParameters.testScope, 'outerloop'), ne(parameters.jobParameters.runtimeFlavor, 'mono')) }}:
          - ${{ if or(eq(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
            - Windows.11.Amd64.Client.Open
            - Windows.Amd64.Server2022.Open
          - ${{ if or(ne(parameters.jobParameters.isExtraPlatformsBuild, true), eq(parameters.jobParameters.includeAllPlatforms, true)) }}:
            - Windows.Amd64.Server2022.Open
            - Windows.7.Amd64.Open

      # .NETFramework
      - ${{ if eq(parameters.jobParameters.framework, 'net48') }}:
        - Windows.10.Amd64.Client.Open

    # windows arm64
    - ${{ if eq(parameters.platform, 'windows_arm64') }}:
      - Windows.11.Arm64.Open

    # WASI
    - ${{ if eq(parameters.platform, 'wasi_wasm') }}:
      - (Ubuntu.2204.Amd64)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-helix-webassembly

    # Browser WebAssembly
    - ${{ if eq(parameters.platform, 'browser_wasm') }}:
      - (Ubuntu.2204.Amd64)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-helix-webassembly

    # Browser WebAssembly Firefox
    - ${{ if eq(parameters.platform, 'browser_wasm_firefox') }}:
      - (Ubuntu.2204.Amd64)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-helix-webassembly

    # Browser WebAssembly windows
    - ${{ if in(parameters.platform, 'browser_wasm_win', 'wasi_wasm_win') }}:
      - (Windows.Amd64.Server2022.Open)windows.amd64.server2022.open@mcr.microsoft.com/dotnet-buildtools/prereqs:windowsservercore-ltsc2022-helix-webassembly

    ${{ insert }}: ${{ parameters.jobParameters }}
